let buf1 = Buffer.alloc(6,0xff)
console.log(buf1);
//分配可能在使用的内存
let buf2 = Buffer.allocUnsafe(6)
console.log(buf2);
let buf3 = Buffer.from('聂良')
console.log(buf3);
let buf4 = Buffer.alloc(6)
console.log(buf4);
//值 开始 结束索引  通常包含前面 不包含后面
buf4.fill(3,1,3)
console.log(buf4);
// 写的字符串 开始索引 长度 编码
buf4.write('聂良',0,3,'utf8')
console.log(buf4.toString());
buf4.write('良',3,3,'utf8')
console.log(buf4.toString());
let buf5 = Buffer.alloc(6)
// 指定索引写入一个8位整数
buf5.writeInt8(0,0)
buf5.writeInt8(16,1)
buf5.writeInt8(32,2)
// buf5.writeInt16(0x112,4)
console.log('rr',buf5.toString());
let buf6 = Buffer.alloc(8)
// be高位在前 le低位在前
buf6.writeInt16BE(256,0)
buf6.writeInt16LE(256,2)
console.log('45',buf6);
// 16机制存储数组 -- 
console.log('ee',buf6.toString('utf8'));
let buf7 = Buffer.alloc(8)
buf7 = buf6.slice(2,4) //浅拷贝
console.log(buf7);
buf6.fill(1)
console.log(buf7);

// toString，，，
// string_decoder
let buf8 = Buffer.from('祝福技术')
console.log(buf8);
buf9 = buf8.slice(0,7)
let {StringDecoder} = require('string_decoder')
let sd = new StringDecoder()
//需要顺序 乱码缓存，，，
console.log('ee',sd.write(buf8.slice(7)));
console.log(sd.write(buf9));

console.log(buf9.toString());
console.log(buf9);
// 二进制容器

//unit8Array 子类

let b1 = Buffer.from('🐖')
let b2 = Buffer.from('🐶')
let result = Buffer.concat([b1,b2])
console.log('rk',result);
console.log('rk',result.toString());
// Buffer固定长度的














